package com.studio49.exmple.service.appInterface.impl;

import java.util.List;

import com.studio49.exmple.core.entity.pub.JsonResult;
import com.studio49.exmple.core.entity.pub.PageView;
import com.studio49.exmple.entity.web.product.Notice;
import com.studio49.exmple.mapper.web.product.NoticeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.studio49.exmple.service.appInterface.AppProductService;

@Service
public class AppProductServiceImpl implements AppProductService {
	
	@Autowired
	private NoticeMapper noticeMapper;

	@Override
	public JsonResult findAppNoticeListByPage(Integer pageNum, Integer pageSize) throws Exception {

		JsonResult jsonResult = new JsonResult(true);
		
		if(pageNum == null) {
			pageNum = 1;
		}
		if(pageSize == null) {
			pageSize = 10;
		}
		PageHelper.startPage(pageNum, pageSize);
		List<Notice> list = noticeMapper.findActiveNotice();
		PageView pageView = new PageView(list);
		
		jsonResult.setObj(pageView);
		jsonResult.setMsg("查询公告成功");
		jsonResult.setSuccess(true);
		return jsonResult;
	
	}

}
